
import {defineStore} from 'pinia'
import {reqLogin} from '@/apis'
import {getToken, setToken} from '@/utils/token'

import {type ResponseData} from '../type'
export const useUserStore = defineStore('user', {
    state: () => ({
        token: getToken() || '',
        userInfo: {
            username: '',
            avatar: ''
        }
    }),
    actions: {
        async doLogin(data: any) {
            const res:ResponseData = await reqLogin(data)
            if (res.code == 200) {
                // 登录成功
                // 保存token
                setToken(this.token)

            }

        }
    }

})
